<template>
  <div>
    <div style="background-color: #FFFFFF;width: 100%;height: 900px">
      <!--      上半部分统计-->
      <div style="display: flex;padding: 30px">
        <div style="width: 100%;height: 180px;background-color: #EAEAEA;display: flex;align-items: center">
          <div style="background-color: #FFFFFF;width: 300px;height: 92px;margin-left:30px;display: flex;align-items: center;padding: 20px">
            <el-image style="width: 60px; height: 60px" :src="require('@/assets/jibi.png')"></el-image>
            <div style="margin-left: 20px">
              <div style="font-size: 20px;font-weight: normal;line-height: normal;letter-spacing: 0em;">消费卷兑换总次数</div>
              <div style="font-size: 25px;font-weight: 500;line-height: 35px;letter-spacing: 0em;color: #3662EC;">{{charts.totalProvideCoupon}}</div>
            </div>
          </div>
          <div style="background-color: #FFFFFF;width: 300px;height: 92px;margin-left:60px;display: flex;align-items: center;padding: 20px">
            <el-image style="width: 60px; height: 60px" :src="require('@/assets/fz.png')"></el-image>
            <div style="margin-left: 20px">
              <div style="font-size: 20px;font-weight: normal;line-height: normal;letter-spacing: 0em;">兑换总积分</div>
              <div style="font-size: 25px;font-weight: 500;line-height: 35px;letter-spacing: 0em;color: #FF6161;">{{charts.totalPoint}}</div>
            </div>
          </div>
        </div>
      </div>
<!--      下半部分列表 -->
      <div style="padding: 30px">
        <div style="font-size: 20px;margin-bottom: 20px">账单列表</div>
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="100px">
          <el-form-item label="店铺名称" prop="productName">
            <el-input v-model="queryParams.shopName" placeholder="请输入消费卷类型" clearable @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item label="店铺账号" prop="proCode">
            <el-input v-model="queryParams.proCode" placeholder="请输入消费卷名称" clearable @keyup.enter.native="handleQuery" />
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>
        <el-table v-loading="loading" :data="inventoryList">
          <el-table-column label="序号" type="index" width="50" />
          <el-table-column label="店铺名称" align="center" prop="shopName" />
          <el-table-column label="店铺账号" align="center" prop="account" />
          <el-table-column label="月消费卷兑换次数" align="center" prop="provideCouponCountPerMonth" />
          <el-table-column label="月兑换总积分" align="center" prop="totalPointPerMonth">
          </el-table-column>
          <el-table-column label="入账年月" align="center" prop="yearMonth" />
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.current" :limit.sync="queryParams.size"
                    @pagination="getList" />
      </div>
      <el-dialog title="银行卡列表" :visible.sync="dialogTableVisible" width="1000px">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['user:team:add']"
        >新增
        </el-button>
        <el-table :data="gridData">
          <el-table-column label="序号" type="index" width="50" />
          <el-table-column label="开户人" align="center" prop="accountHolder" />
          <el-table-column label="银行预留手机号" align="center" prop="accountHolderPhone" />
          <el-table-column label="银行卡号" align="center" prop="bankCardNumber" />
          <el-table-column label="开户行地址" align="center" prop="bankAddressDetail" />
          <el-table-column label="开户行" align="center" prop="bankName" />
          <el-table-column label="开户行号" align="center" prop="bankNumber" />
          <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="text"
                icon="el-icon-edit"
                @click="handleUpdate(scope.row,scope.$index)"
                v-hasPermi="['user:team:edit']"
              >修改
              </el-button>
              <el-button
                size="mini"
                type="text"
                icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-hasPermi="['user:team:remove']"
              >删除
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-dialog :title="title" :visible.sync="dialogadd" width="500px">
          <el-form ref="bankCard" :model="bankCard" :rules="rules" label-width="120px">
            <el-form-item label="开户人" prop="accountHolder">
              <el-input v-model="bankCard.accountHolder" placeholder="请输入开户人"/>
            </el-form-item>
            <el-form-item label="开户预留电话" prop="accountHolderPhone">
              <el-input v-model="bankCard.accountHolderPhone" placeholder="请输入开户预留电话"/>
            </el-form-item>
            <el-form-item label="开户行" prop="accountHolder">
              <el-input v-model="bankCard.bankName" placeholder="请输入开户行"/>
            </el-form-item>
            <el-form-item label="银行卡号" prop="bankCardNumber">
              <el-input v-model="bankCard.bankCardNumber" placeholder="请输入银行卡号"/>
            </el-form-item>
            <el-form-item label="开户行详细地址" prop="bankAddressDetail">
              <el-input v-model="bankCard.bankAddressDetail" placeholder="请输入开户人"/>
            </el-form-item>
            <el-form-item label="开户行号" prop="bankNumber">
              <el-input v-model="bankCard.bankNumber" placeholder="请输入开户行号"/>
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitForm">确 定</el-button>
            <el-button @click="dialogadd = false">取 消</el-button>
          </div>
        </el-dialog>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import {
  analyseData,
  applyFromPage,
  bankCardadd,
  bankCarddelete,
  bankCardlist,
  bankCardupdate
} from '@/api/property/property'
import { addTeam, delTeam, updateTeam } from '@/api/system/team'
import { marketingListApi } from '@/api/marketing'
import { couponAnalysis, couponAnalysispage } from '@/api/supermarket/monthlybill'

export default {
  name: 'overview',
  data(){
    return{
      queryParams: {
        current: 1,
        size: 10,
        createDate: null,
        name: null,
        type: null,
      },
      total:0,
      loading:false,
      charts:{},
      inventoryList:[],
      // 银行卡列表
      gridData:[],
      dialogTableVisible:false,
      dialogadd:false,
      querybankCard:{
        current:1,
        size:10
      },
      title:'添加银行卡号',
      // 表单校验
      rules: {
        accountHolder: [
          { required: true, message: '请输入开户人', trigger: 'change' }
        ],
        accountHolderPhone: [
          { required: true, message: '请输入开户预留电话', trigger: 'change' }
        ],
        bankCardNumber: [
          { required: true, message: '请输入银行卡号', trigger: 'change' }
        ],
        bankName: [
          { required: true, message: '请输入开户行', trigger: 'change' }
        ]
      },
      bankCard:{
        accountHolder: "",
        accountHolderPhone: "",
        bankAddressDetail: "",
        bankAddressId: 0,
        bankCardNumber: "",
        bankName: "",
        bankNumber: "",
        id: 0,
        idCardNumber: ""
      },
    }
  },
  created() {
    this.getList()
    // 获取统计
    this.getchart()
  },
  methods:{
    getList(){
      this.loading = true
      couponAnalysispage(this.queryParams).then(res=>{
        this.inventoryList = res.pageData
        this.loading = false
        this.total = Number(res.total)
      })
    },
    getchart(){
      couponAnalysis().then(res =>{
        this.charts = res
      })
    },
    // 添加保存
    submitForm(){
      this.$refs['bankCard'].validate(valid => {
        if (valid) {
          if (this.title ==  '修改信息') {
            bankCardupdate(this.bankCard).then(response => {
              this.$modal.msgSuccess('修改成功')
              this.dialogadd = false
              this.hanrdlist()
            })
          } else {
            bankCardadd (this.bankCard).then(response => {
              this.$modal.msgSuccess('新增成功')
              this.dialogadd = false
              this.hanrdlist()
            })
          }
        }
      })
    },
    handleAdd(){
      this.dialogadd = true
      this.bankCard={
        accountHolder: "",
        accountHolderPhone: "",
        bankAddressDetail: "",
        bankAddressId: 0,
        bankCardNumber: "",
        bankName: "",
        bankNumber: "",
        id: 0,
        idCardNumber: ""
      }
    },
    // 银行卡号修改
    handleUpdate(e){
      this.title = '修改信息'
      this.dialogadd = true
      this.bankCard = e
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const pkIds = row.id || this.ids
      this.$modal.confirm('是否确认删除该银行卡？').then(function() {
        return bankCarddelete(pkIds)
      }).then(() => {
        this.hanrdlist()
        this.$modal.msgSuccess('删除成功')
      }).catch(() => {
      })
    },
    getfalg(e){
      e==3?this.queryParams.status=null:e==0?this.queryParams.status=0:e==1?this.queryParams.status=1:this.queryParams.status=2
      this.getList()
    },
    //银行卡提现
    hanrdlist(){
      bankCardlist(this.querybankCard).then(res=>{
        this.dialogTableVisible = true
        this.gridData = res.pageData
      })
    },
    // 跳转提现
    getrouter(){
      this.$router.push('/marketing/addcoupon')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.current = 1;
      console.log(this.queryParams)
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
}
</script>

<style scoped>
.card-1{
  width: 220px;
  height: 80px;
  background-color: #FFFFFF;
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.card-1-text{

}
.card-1-text-top{
  font-size: 20px;
  margin-bottom:10px ;
}
.botten-yes {
  width: 138px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(24, 144, 255, 0.15);
  box-sizing: border-box;
  border-width: 0px 0px 2px 0px;
  border-style: solid;
  border-color: #1890FF;
}

.botten-no {
  width: 138px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  border-width: 0px 0px 0px 0px;
  border-style: solid;
}
</style>
